#ifndef __STDMYSTRING_H__
#define __STDMYSTRING_H__
#include<iostream>
class MyStringList;//前置声明
class StdMyString
{

public:
    StdMyString();
    StdMyString(const char *str);
    StdMyString(const StdMyString &str);
    ~StdMyString();

    StdMyString& operator=(const StdMyString &str);
    StdMyString &operator+=(const StdMyString &str);
    StdMyString operator+(const StdMyString & str);
    StdMyString& operator-=(const StdMyString & str);
    StdMyString operator-(const StdMyString & str);
    StdMyString &operator+=(const char &c);
    char &operator[](int index);

    //逻辑运算符
    bool operator==(const StdMyString &str);
    bool operator>(const StdMyString &str);
    bool operator<(const StdMyString &str);

    friend std::ostream &operator<<(std::ostream &os, const StdMyString &str);
    friend std::istream &operator>>(std::istream &is,StdMyString &str);

    operator int();
    operator double();

    //字符串切割函数
    MyStringList split(const StdMyString &str);

private:
    char *string;
    int size;
    int capacity;
};
std::ostream &operator<<(std::ostream &os, const StdMyString &str);
std::istream &operator>>(std::istream &is,StdMyString &str);

class MyStringList
{
    //- -= == > < [] >>
public:
    MyStringList(int capacity=15);
    MyStringList(const MyStringList &list);
    ~MyStringList();
    MyStringList& operator=(const MyStringList & list);
    MyStringList &operator+=(const StdMyString &str);
    MyStringList operator+(const MyStringList &list);
    MyStringList &operator-=(const StdMyString &str);
    MyStringList &operator<<(const StdMyString &str);
    

    friend std::ostream &operator<<(std::ostream &os, const MyStringList &list);
public:
    StdMyString *array;
    int size;
    int capacity;
};
std::ostream &operator<<(std::ostream &os, const MyStringList &list);

#endif